<%-- 
    Document   : index
    Created on : 2010/10/25, 下午 05:14:02
    Author     : stan
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" >
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <script type="text/javascript" src="js/jquery.js"></script>
        <script type="text/javascript" src="js/jquery.livequery.js"></script>
        <script type="text/javascript" src="js/foodMate.js"></script>
        <script type="text/javascript" src="js/jquery.ui.core.js"></script>
        <script type="text/javascript" src="js/jquery.ui.datepicker.js"></script>

        <div id="fb-root"></div>
        <script src="http://connect.facebook.net/en_US/all.js"></script>
        <script>
          window.fbAsyncInit = function() {
            FB.init({
              appId  : '173022209379663',
              status : true, // check login status
              cookie : true, // enable cookies to allow the server to access the session
              xfbml  : true  // parse XFBML
            });
          };


          (function() {
            var e = document.createElement('script');
            e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
            e.async = true;
            document.getElementById('fb-root').appendChild(e);
          }());

           

          
           var Authen = $('#Authen');
           Authen.livequery('mouseup', function(e) {
                window.location = "https://graph.facebook.com/oauth/authorize?client_id=173022209379663&redirect_uri=http://sexy4foodmate.dyndns-ip.com:8080/FoodMateService-war/&type=user_agent&display=popup";
            });
            var Authen1 = $('#Authen1');
           Authen1.livequery('mouseup', function(e) {
               FB.getLoginStatus(function(response) {
                   if (response.session) {
                  // logged in and connected user, someone you know
                         //alert(response.session.uid);
                         $("#FBid").val(response.session.uid);
                         $("#FBid2").val(response.session.uid);
                         $("#FBid3").val(response.session.uid);
                         //$("#facebookid").val(response.session.uid);
                    } else {
                 // no user session available, someone you dont know
                         alert("Please try again..Here's something wrong from FB..");
                      }
                 });

            });

           var Admin = $('#Admin');
           Admin.livequery('mouseup', function(e) {
               FB.getLoginStatus(function(response) {
                   if (response.session) {
                  // logged in and connected user, someone you know
                         //alert(response.session.uid);
                         $("#FBid3").val(response.session.uid);
                         //$("#facebookid").val(response.session.uid);
                    } else {
                 // no user session available, someone you dont know
                         alert("Please try again..Here's something wrong from FB..");
                      }
                 });

            });



        </script>
        <div id="Authen"><fb:login-button autologoutlink="True" length="short" background="white" size="large"></fb:login-button></div>
        <fb:profile-pic uid="loggedinuser" facebook-logo="true" linked="false"></fb:profile-pic>
        <fb:name uid="loggedinuser" useyou="false"/></fb:name>
        <p></p>
        <h1 id ="helloWorld">FoodMate!</h1>

        <%
           String name = request.getParameter( "username" );
           session.setAttribute( "theName", name );
        %>
        Hello, <%= (String) session.getAttribute( "theName" ) %>

        <div id="AdminPage">
            <form method="GET" action="AdminPage">
              <INPUT id="FBid3" TYPE=hidden NAME=username3 SIZE=20>
           <!--   <INPUT id="realName3" TYPE=hidden NAME=realName SIZE=20> -->
              <p><input id="Admin" type="submit" value="Enter Admin Page" name="btnAdminPage" ></p>
            </form>
        </div>

        <div id="PersonalInfo">
            <form method="GET" action="PersonalInfo">
              <INPUT id="FBid2" TYPE=hidden NAME=username2 SIZE=20>
              <!--<INPUT id="realName2" TYPE=hidden NAME=realName SIZE=20>-->
              <p><input id="Authen1" type="submit" value="Maintain Personal Info" name="btnPersonalInfo" ></p>
            </form>
        </div>

        <a href="addRest.jsp">Click here to insert Resturant Info</a>

        <div id="SelectRest">
            <form method="GET" action="FoodMateServlet">
              <div> Style
                    <SELECT NAME="Style"">
                    <OPTION VALUE="Itlian">Itlian
                    <OPTION VALUE="Chinese">Chinese
                    <OPTION VALUE="Japanese">Japanese
                    <OPTION VALUE="Maxican">Maxican
                    <OPTION VALUE="American">American
                    </SELECT>
              </div>
              <div> Location
                <SELECT NAME="Location"">
                <OPTION VALUE="Manhattan">Manhattan
                <OPTION VALUE="Brooklyn">Brooklyn
                <OPTION VALUE="Queen">Queen
                <OPTION VALUE="Island">Long Island
                </SELECT>
              </div>
              <div> Restaurant name  <input type="text" name="RestaurantName" size="30"></div>
              <INPUT id="FBid" TYPE=hidden NAME=username SIZE=20>
              <INPUT id="realName" TYPE=hidden NAME=realName SIZE=20>
              <p><input id="Authen1" type="submit" value="Submit" name="B1" ></p>
            </form>
        </div>
    </body>
</html>
